<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <#include "../common/header.ftl">
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <style>
        .modal-body img{
            width: 100%;
        }

        .modal-body{
            max-height: 500px;
            overflow-y: scroll;
        }

        #skip{
            display: none;
        }
    </style>

    <script type="text/javascript">
        $(function(){

            $('#pagination').twbsPagination({
                        totalPages:${result.pages} || 1,
                    startPage:${result.pageNum},
            visiblePages:${result.pageSize},
            first:"首页",
                    prev:"上页",
                    next:"下页",
                    last:"尾页",
                    //event 表示事件对象
                    //page 表示页码: 当前页
                    onPageClick:function(event, page){
                //讲当前页设置page值
                $("#currentPage").val(page);
                //表单提交
                $("#searchForm").submit();
            }
        });

            //查看文章内容
            $(".showContentBtn").click(function(){
                //获取游记的id
                var id = $(this).data("tid");
                $.get("/travel/getContentById.do",{id:id},function(data){
                    $(".modal-body").html(data.content);
                    $("#contentModal").modal('show');
                })
            })

            //取消发布按钮
            $(".changeSateBtn").click(function(){
                //获取游记的id
                var id = $(this).data("tid");
                //设置为待发布状态
                $.get("/travel/changeState.do",{id:id,state:1},function(data){
                    showMessager(data);
                })
            })

            //游记推荐按钮
            $(".commendBtn").click(function(){
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                $("#title").val(json.title);
                //封面
                $("#coverImg").attr('src',json.coverUrl);
                $("#coverUrl").val(json.coverUrl);
                //设置游记id
                $("#travelId").val(json.id);
                $("#commendModal").modal('show');
            })

            //保存游记推荐按钮
            $("#saveBtn").click(function () {
                $("#editForm").ajaxSubmit(function(data){
                    showMessager(data);
                })
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">已发布游记列表</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travelRelease/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}" placeholder="请输入游记标题">
                </div>
                <button id="btn_query" class="btn btn-default">查询</button>

            </form>

            <table class="table table-striped table-hover" >
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>状态</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.title}</td>
                    <td><img src="${entity.coverUrl}" width="50px"/> </td>
                    <td>${(entity.place.name)!}</td>
                    <td>${(entity.author.nickName)!}</td>
                    <td>
                        <#if entity.state==-1>
                            拒绝
                        <#elseif entity.state==0>
                            草稿
                        <#elseif entity.state==1>
                            待发布
                        <#elseif entity.state==2>
                            已发布
                        </#if>
                    </td>
                    <td><a href="javascript:void(0);" class="changeSateBtn" data-tid='${entity.id}'>取消发布</a></td>
                    <td><a href="javascript:void(0);" class="showContentBtn" data-tid='${entity.id}'>查看内容</a></td>
                    <td><a href="javascript:void(0);" class="commendBtn" data-json='${entity.jsonString}'>推荐</a></td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="contentModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">查看游记内容</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!--游记推荐模态窗-->
<#include "../travel/editModal.ftl">


</body>
</html>